package com.iotimc.attendancesystem.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * @author david
 */
public class BootRestartReceiver extends BroadcastReceiver {
    private final String ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(ACTION)) {
            Intent intent2 = context.getPackageManager()
                    .getLaunchIntentForPackage(context.getPackageName());
            intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            context.startActivity(intent2);
            Log.i("BootRestartReceiver", "开机自动服务自动启动...");
        }

    }
}
